import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Card-卡片组件',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Card-卡片组件'),
        ),
        body: DemoPage(),
      ),
    );
  }
}

class DemoPage extends StatefulWidget{
  @override
  DemoPageState createState() => DemoPageState();
}

class DemoPageState extends State{
  @override
  Widget build(BuildContext context) {
    return Card(
      color: Colors.green,
      elevation: 20,
      margin: EdgeInsets.all(20),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(20)
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          ListTile(
            leading: Icon(Icons.shopping_cart),
            title: Text('这是一台苹果电脑',
                style:TextStyle(color: Colors.white,fontSize: 40),
            ),
            subtitle: Text('配置为16核 8G内存',
              style: TextStyle(color: Colors.white,fontSize: 16),
            ),
            contentPadding: EdgeInsets.all(20),
          ),
          //2个按钮
          ButtonTheme(child: ButtonBar(
            children: [
              FlatButton(onPressed: (){}, child: Text('buy',style: TextStyle(color: Colors.red,fontSize: 14),)),
              FlatButton(onPressed: (){}, child: Text('cancle',style: TextStyle(color: Colors.grey,fontSize: 14))),
            ],
          ),)
        ],
      ),
    );
  }
}